import cv2
import numpy as np

path = r"C:\ProgramData\Anaconda3\envs\python-stu\Library\etc\haarcascades\haarcascade_frontalface_default.xml"
face_cascade = cv2.CascadeClassifier(path)
capNo =1

cap = cv2.VideoCapture(capNo)

cap.open(capNo)
capName = ''
if capNo == 0:
    capName = "Camera@Dell"
else:
    capName = "Camer@Logitech"

while True:
    ret, frame = cap.read()
    faces = face_cascade.detectMultiScale(frame, 1.3, 2)
    img=frame
    for(x,y,w,h) in faces:
        img=cv2.rectangle(img,(x,y),(x+w,y+h),(25,4,215),2)
        face_area=img[y:y+h,x:x+w]

    cv2.imshow(capName,img)
    key_pressed = cv2.waitKey(60)
    print(">>>", key_pressed)
    cv2.moveWindow(capName, 0, 0)
    if key_pressed == 27:
        break
cap.release()

cv2.destroyAllWindows()
